/* 到货通知物料信息行数据 */
import { requestClient } from '#/api/request';

export namespace ItemRecptLine {
  export interface Params {
    attr1: null;
  }
  export interface Detail {
    searchValue: null;
    createBy: string;
    createTime: Date;
    updateBy: string;
    updateTime: null;
    remark: string;
    params: Params;
    detailId: number;
    lineId: number;
    recptId: number;
    itemId: number;
    itemCode: string;
    itemName: string;
    specification: string;
    unitOfMeasure: string;
    unitName: null;
    quantity: number;
    batchId: number;
    batchCode: string;
    warehouseId: number;
    warehouseCode: string;
    warehouseName: string;
    locationId: number;
    locationCode: string;
    locationName: string;
    areaId: number;
    areaCode: string;
    areaName: string;
    attr1: null;
    attr2: null;
    attr3: number;
    attr4: number;
  }

  export interface Row {
    searchValue: null;
    createBy: string;
    createTime: Date;
    updateBy: string;
    updateTime: null;
    remark: string;
    params: Params;
    lineId: number;
    recptId: number;
    noticeLineId?: number;
    itemId: number;
    itemCode: string;
    itemName: string;
    specification: null;
    unitOfMeasure: string;
    unitName: null | string;
    quantityRecived?: number;
    batchId: null;
    batchCode: null;
    warehouseId: null | number;
    warehouseCode: null | string;
    warehouseName: null | string;
    locationId: null | number;
    locationCode: null | string;
    locationName: null | string;
    areaId: null | number;
    areaCode: null | string;
    areaName: null | string;
    expireDate?: null;
    produceDate?: null;
    lotNumber?: null;
    iqcCheck?: string;
    iqcId?: null;
    iqcCode?: null;
    attr1: boolean | null | string;
    attr2: null;
    attr3: number;
    attr4: number;
    details?: Detail[];
    detailId?: number;
    quantity?: number;
  }
  export interface GetListParams {
    pageNum: number;
    pageSize: number;
    recptId: number;
  }
  export interface GetListReturn {
    total: number;
    rows: Row[];
    code: number;
    msg: string;
  }
}

// 获取列表及详情
export const getItemRecptLineAndDetailTableList = (
  params: ItemRecptLine.GetListParams,
) =>
  requestClient.get<ItemRecptLine.GetListReturn>(
    '/mes/wm/itemrecptline/listWithDetail',
    {
      params,
    },
  );
export const getItemRecptLineTableList = (
  params: ItemRecptLine.GetListParams,
) =>
  requestClient.get<ItemRecptLine.GetListReturn>('/mes/wm/itemrecptline/list', {
    params,
  });

// 增加入库单行信息
export const addItemRecptLine = (data: ItemRecptLine.Row) =>
  requestClient.post<ItemRecptLine.GetListReturn>(
    '/mes/wm/itemrecptline',
    data,
  );

// 删除入库单行信息
export const deleteItemRecptLine = (id: string) =>
  requestClient.delete<ItemRecptLine.GetListReturn>(
    `/mes/wm/itemrecptline/${id}`,
  );

// 修改入库单设置
export const updateItemRecptLine = (data: ItemRecptLine.Row) =>
  requestClient.put<ItemRecptLine.GetListReturn>('/mes/wm/itemrecptline', data);
